
//校验数据库
function validateRedisDriverConfig(driver, $this, driverConfig){
	var name = $this.find("input[name='name']").val();
	var password = $this.find("input[name='password']").val();
	var key = $this.find("input[name='key']").val().toLocaleUpperCase();
	var url = $this.find("textarea[name='url']").val();
	driverConfig.url=url;
	driverConfig.password=password;
	driverConfig.key=key;
	driverConfig.name=name;
	
	// 如果默认redis字段为空,则使用数据源字段,否则使用自定义字段
	var metaInfo = $this.find("#driverRedisParamsContainer .form-group");
	var $fParam = $(metaInfo[0]).find('input[name="filedName"]');
	var mLen = metaInfo.length;
	if(1 < mLen || "" != $fParam.val()){
		var cols = [];
		for (var i = 0; i < mLen; i++) {
			var col = $(metaInfo[i]);
			var filedName = col.find('input[name="filedName"]').val();
			var filedType = col.find('select[name="filedTypeName"]').val();
			var filedTypeName = col.find('option:selected').text();
			cols.push({
				"name" : filedName.toLocaleUpperCase(),
				"typeName" : filedTypeName,
				"type" : filedType
			});
		}
		driverConfig.column = cols;
	}else{
		// 移除必填校验
		$fParam.removeAttr("asd-valid");
		driverConfig.column = driver.sourceMapping.config.column;
	}
	
	//校验表单
	if($this.formValidate()==false){
		return null;
	}
	
	//读取连接信息
	var result;
	var isSuccess;
	$.ajax({  
		url : $basePath + "/driver/getRedisConnector",  
		contentType:"application/x-www-form-urlencoded",
	    type : "post",  
	    data : driverConfig,  
	    async : false,
	    success : function(data){
	    	isSuccess = data.success;
	    	if(isSuccess){
	    		result = data.resultValue;
	    	}else{
	    		bootGrowl(data.resultValue,"danger"); 
	    	}
	    }
    });

	if(!isSuccess){
		return null;
	}
	return result;
}

